<?php
require("core.php");
$sql = "select aid,title,ut from acticle";
$sql2 = "select COUNT(*) c from acticle";
$page = 0;
$url = "list.php?";

if(isset($_GET['t']) && intval($_GET['t']) > 0) 
{
	$sql .= " where tpid=".intval($_GET['t']);
	$sql2 .= " where tpid=".intval($_GET['t']);
	$url .= "t=".intval($_GET['t']);
}

if(isset($_GET['p']) && intval($_GET['p']) > 0) $page = intval($_GET['p']) - 1;

$sql .= " order by aid desc limit ".($page*20).",20";
$list = $g_db->query($sql);
$rn = $g_db->query($sql2);
$blist = getJson("data/list.json");
include("include/head.php");
?>
<div class='con'>
<div class='cbody'>
<div class='clist' id="clist">
<?php
$jlist = getJson("data/list.json");
if(isset($jlist[intval($_GET['t'])]))
{
	if(intval($_GET['t']) == 0){
		foreach($jlist[intval($_GET['t'])] as $k=>$v){
			echo "<a href='/view.php?a=",($k+1),"'>",$v[1],"</a><br/>";
		} 
	}else{
		foreach($jlist[intval($_GET['t'])] as $v) echo "<a href='",$v[0],"'>",$v[1],"</a><br/>";
	}
}
foreach($list as $v)
{
	echo "<a href='view.php?a=",$v['aid'],"'>",$v['title'],"<span>",date('Y-m-d',$v['ut']),"</span></a><br/>";
}
?>
</div>
<div class="ccr">
	<div class='clput'>
		<div class="tt">看了再看</div>
	<?php
	$len = count($blist[0]);
	for($i=0;$i<10;$i++)
	{
		echo "<a href='view.php?a=",($len-$i),"'>",$blist[0][$len-$i-1][1],"</a>";
	}
	?>
	</div>
	<div id="ad3">
	<script type="text/javascript">
		/*webjia_right*/
		var cpro_id = "u2935358";
	</script>
	<script type="text/javascript" src="http://cpro.baidustatic.com/cpro/ui/c.js"></script>
	</div>	
</div>
<div class="pgl"><?php 
	echo "<a href=",$url,"> << </a>";
	if($page > 0) echo "<a href=",$url,"&p=",$page,"> < </a>";
	echo "<a href=",$url,"&p=",$page+1,"> ",($page+1)," </a>";
	if($page < intval($rn[0]['c']/20)) echo "<a href=",$url,"&p=",$page+2,"> > </a>";
	echo "<a href=",$url,"&p=",intval($rn[0]['c']/20+1),"> >> </a>";
?></div>
</div>
</div>
<?php
include("include/foot.php");